package com.atguigu.gmall.logger.controller;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Author: Felix
 * Date: 2022/3/9
 * Desc: SpringMVC处理请求回顾
 *      @Controller
 *          将当前类对象的创建交给容器管理，如果这个类中方法的返回值是String类型，会进行页面跳转
 *          如果不想进行页面跳转，只是返回普通的字符串，需要在方法上加一个注解@ResponseBody
 *      @RestController
 *          等价于 @Controller + @ResponseBody
 */
//@Controller
@RestController
public class FirstController {

    //   http://localhost:8080/aa/first?username=zs&password=123
    //RequestMapping 拦截请求，将请求交给当前方法进行处理
    @RequestMapping("/first")
    //@ResponseBody
    public String first(
        @RequestParam("aaa") String username,
        @RequestParam(value = "bbb",defaultValue = "atguigu") String password){
        System.out.println(username + ":::" + password);
        return "success";
    }
}
